/**
 * Created by yangshengjiepro on 15/5/29.
 */
var _GameOver =null;
var GameOver = BaseLayer.extend({
    init:function(_upLayer,score){
        if (_upLayer != null) {
            Mlog.c("11111");
            var tipbd =   cc.Sprite.create(res.UI_GOBD);
            tipbd.setAnchorPoint(cc.p(0.5,0.5));
            tipbd.setPosition(_upLayer.getContentSize().width/2,_upLayer.getContentSize().height/2+88);
            this.addChild(tipbd,2);

            var fenshu = cc.LabelTTF.create(score+"","微软雅黑",60+6);
            fenshu.setAnchorPoint(cc.p(0,0.5));

            fenshu.setPosition(cc.p(tipbd.getContentSize().width/2+46,tipbd.getContentSize().height/2+36))
            tipbd.addChild(fenshu);

            var url =res.UI_no1;
            if(parseInt(score)>=0&&parseInt(score)<10)
            {
                url =res.UI_no1;
                fenshu.setColor(new cc.Color(0,0,0,0));
            }
            else if(parseInt(score)>=10&&parseInt(score)<20)
            {
                url =res.UI_no2;
                fenshu.setColor(new cc.Color(153,102,255,0));
            }
            else if(parseInt(score)>=20&&parseInt(score)<30)
            {
                url =res.UI_ok0;
                fenshu.setColor(new cc.Color(0,153,204,0));
            }
            else if(parseInt(score)>=30&&parseInt(score)<100)
            {
                url =res.UI_ok1;
                fenshu.setColor(new cc.Color(255,0,0,0));
            }
            else if(parseInt(score)>=100)
            {
                url =res.UI_ok2;
                fenshu.setColor(new cc.Color(255,0,0,0));
            }

            var tipzi = cc.Sprite.create(url);
            tipzi.setAnchorPoint(cc.p(0.5,0.5));
            tipzi.x = tipbd.getContentSize().width/2;
            tipzi.y = tipbd.getContentSize().height/2-30;
            tipbd.addChild(tipzi);

            _upLayer.addChild(this,100000);

            return true;
        }
        else
        {
            return false;
        }
    },
    ctor:function () {
        this._oktouch=false;//关闭点不透
        this._showbg=true;//开启背景
        this._showbgAcion=true;
        this._super();
    }
});

GameOver.toClose = function(){
    if(_GameOver!=null)
    {
        _GameOver.removeFromParent();
        _GameOver=null;
    }
};

GameOver.toRun = function(_upLayer,score){
    if(_upLayer==null)
    {
        return;
    }
    var nowlayer = new GameOver();
    _GameOver=nowlayer;
    if(nowlayer.init(_upLayer,score)==true)
    {
        Mlog.c("open GameOver");
    }
};